<HTML>
<HEAD>
<!-- Created by texi2html 1.56k from libavfilter.texi on 15 April 2010 -->

<TITLE>Libavfilter Documentation</TITLE>
</HEAD>
<BODY>
<H1>Libavfilter Documentation</H1>
<P>
<P><HR><P>
<H1>Table of Contents</H1>
<UL>
<LI><A NAME="TOC1" HREF="libavfilter.html#SEC1">1. Introduction</A>
<LI><A NAME="TOC2" HREF="libavfilter.html#SEC2">2. Tutorial</A>
<LI><A NAME="TOC3" HREF="libavfilter.html#SEC3">3. graph2dot</A>
<LI><A NAME="TOC4" HREF="libavfilter.html#SEC4">4. Available video filters</A>
<UL>
<LI><A NAME="TOC5" HREF="libavfilter.html#SEC5">4.1 crop</A>
<LI><A NAME="TOC6" HREF="libavfilter.html#SEC6">4.2 drawbox</A>
<LI><A NAME="TOC7" HREF="libavfilter.html#SEC7">4.3 fifo</A>
<LI><A NAME="TOC8" HREF="libavfilter.html#SEC8">4.4 format</A>
<LI><A NAME="TOC9" HREF="libavfilter.html#SEC9">4.5 fps</A>
<LI><A NAME="TOC10" HREF="libavfilter.html#SEC10">4.6 hflip</A>
<LI><A NAME="TOC11" HREF="libavfilter.html#SEC11">4.7 negate</A>
<LI><A NAME="TOC12" HREF="libavfilter.html#SEC12">4.8 noformat</A>
<LI><A NAME="TOC13" HREF="libavfilter.html#SEC13">4.9 null</A>
<LI><A NAME="TOC14" HREF="libavfilter.html#SEC14">4.10 overlay</A>
<LI><A NAME="TOC15" HREF="libavfilter.html#SEC15">4.11 pad</A>
<LI><A NAME="TOC16" HREF="libavfilter.html#SEC16">4.12 rotate</A>
<LI><A NAME="TOC17" HREF="libavfilter.html#SEC17">4.13 scale</A>
<LI><A NAME="TOC18" HREF="libavfilter.html#SEC18">4.14 setpts</A>
<LI><A NAME="TOC19" HREF="libavfilter.html#SEC19">4.15 slicify</A>
<LI><A NAME="TOC20" HREF="libavfilter.html#SEC20">4.16 split</A>
<LI><A NAME="TOC21" HREF="libavfilter.html#SEC21">4.17 transpose</A>
<LI><A NAME="TOC22" HREF="libavfilter.html#SEC22">4.18 unsharp</A>
<LI><A NAME="TOC23" HREF="libavfilter.html#SEC23">4.19 vflip</A>
</UL>
<LI><A NAME="TOC24" HREF="libavfilter.html#SEC24">5. Available video sources</A>
<UL>
<LI><A NAME="TOC25" HREF="libavfilter.html#SEC25">5.1 buffer</A>
<LI><A NAME="TOC26" HREF="libavfilter.html#SEC26">5.2 movie</A>
<LI><A NAME="TOC27" HREF="libavfilter.html#SEC27">5.3 nullsrc</A>
</UL>
<LI><A NAME="TOC28" HREF="libavfilter.html#SEC28">6. Available video sinks</A>
<UL>
<LI><A NAME="TOC29" HREF="libavfilter.html#SEC29">6.1 nullsink</A>
</UL>
</UL>
<P><HR><P>

<P>
Libavfilter Documentation




<H1><A NAME="SEC1" HREF="libavfilter.html#TOC1">1. Introduction</A></H1>

<P>
Libavfilter is the filtering API of FFmpeg. It is the substitute of the
now deprecated 'vhooks' and started as a Google Summer of Code project.


<P>
Integrating libavfilter into the main FFmpeg repository is a work in
progress. If you wish to try the unfinished development code of
libavfilter then check it out from the libavfilter repository into
some directory of your choice by:



<PRE>
   svn checkout svn://svn.ffmpeg.org/soc/libavfilter
</PRE>

<P>
And then read the README file in the top directory to learn how to
integrate it into ffmpeg and ffplay.


<P>
But note that there may still be serious bugs in the code and its API
and ABI should not be considered stable yet!




<H1><A NAME="SEC2" HREF="libavfilter.html#TOC2">2. Tutorial</A></H1>

<P>
In libavfilter, it is possible for filters to have multiple inputs and
multiple outputs.
To illustrate the sorts of things that are possible, we can
use a complex filter graph. For example, the following one:



<PRE>
input --&#62; split --&#62; fifo -----------------------&#62; overlay --&#62; output
            |                                        ^
            |                                        |
            +------&#62; fifo --&#62; crop --&#62; vflip --------+
</PRE>

<P>
splits the stream in two streams, sends one stream through the crop filter
and the vflip filter before merging it back with the other stream by
overlaying it on top. You can use the following command to achieve this:



<PRE>
./ffmpeg -i in.avi -s 240x320 -vfilters "[in] split [T1], fifo, [T2] overlay= 0:240 [out]; [T1] fifo, crop=0:0:-1:240, vflip [T2]
</PRE>

<P>
where input_video.avi has a vertical resolution of 480 pixels. The
result will be that in output the top half of the video is mirrored
onto the bottom half.


<P>
Video filters are loaded using the <VAR>-vfilters</VAR> option passed to
ffmpeg or to ffplay. Filters in the same linear chain are separated by
commas. In our example, <VAR>split, fifo, overlay</VAR> are in one linear
chain, and <VAR>fifo, crop, vflip</VAR> are in another. The points where
the linear chains join are labeled by names enclosed in square
brackets. In our example, that is <VAR>[T1]</VAR> and <VAR>[T2]</VAR>. The magic
labels <VAR>[in]</VAR> and <VAR>[out]</VAR> are the points where video is input
and output.


<P>
Some filters take in input a list of parameters: they are specified
after the filter name and an equal sign, and are separated each other
by a semicolon.


<P>
There exist so-called <VAR>source filters</VAR> that do not have a video
input, and we expect in the future some <VAR>sink filters</VAR> that will
not have video output.




<H1><A NAME="SEC3" HREF="libavfilter.html#TOC3">3. graph2dot</A></H1>

<P>
The <TT>`graph2dot'</TT> program included in the FFmpeg <TT>`tools'</TT>
directory can be used to parse a filter graph description and issue a
corresponding textual representation in the dot language.


<P>
Invoke the command:

<PRE>
graph2dot -h
</PRE>

<P>
to see how to use <TT>`graph2dot'</TT>.


<P>
You can then pass the dot description to the <TT>`dot'</TT> program (from
the graphviz suite of programs) and obtain a graphical representation
of the filter graph.


<P>
For example the sequence of commands:

<PRE>
echo <VAR>GRAPH_DESCRIPTION</VAR> | \
tools/graph2dot -o graph.tmp &#38;&#38; \
dot -Tpng graph.tmp -o graph.png &#38;&#38; \
display graph.png
</PRE>

<P>
can be used to create and display an image representing the graph
described by the <VAR>GRAPH_DESCRIPTION</VAR> string.




<H1><A NAME="SEC4" HREF="libavfilter.html#TOC4">4. Available video filters</A></H1>

<P>
When you configure your FFmpeg build, you can disable any of the
existing video filters.
The configure output will show the video filters included in your
build.


<P>
Below is a description of the currently available video filters.




<H2><A NAME="SEC5" HREF="libavfilter.html#TOC5">4.1 crop</A></H2>

<P>
Crop the input video to x:y:width:height.



<PRE>
./ffmpeg -i in.avi -vfilters "crop=0:0:0:240" out.avi
</PRE>

<P>
"x" and "y" specify the position of the top-left corner of the
output (non-cropped) area.


<P>
The default value of "x" and "y" is 0.


<P>
The "width" and "height" parameters specify the width and height
of the output (non-cropped) area.


<P>
A value of 0 is interpreted as the maximum possible size contained in
the area delimited by the top-left corner at position x:y.


<P>
For example the parameters:



<PRE>
"crop=100:100:0:0"
</PRE>

<P>
will delimit the rectangle with the top-left corner placed at position
100:100 and the right-bottom corner corresponding to the right-bottom
corner of the input image.


<P>
The default value of "width" and "height" is 0.




<H2><A NAME="SEC6" HREF="libavfilter.html#TOC6">4.2 drawbox</A></H2>


<PRE>
./ffmpeg -i in.avi -vfilters "drawbox=10:20:200:60:red" out.avi
</PRE>

<P>
Draw a box with x:y:width:height dimensions in a chosen color.




<H2><A NAME="SEC7" HREF="libavfilter.html#TOC7">4.3 fifo</A></H2>


<PRE>
./ffmpeg -i in.avi -vfilters "fifo" out.avi
</PRE>



<H2><A NAME="SEC8" HREF="libavfilter.html#TOC8">4.4 format</A></H2>

<P>
Convert the input video to one of the specified pixel formats.
Libavfilter will try to pick one that is supported for the input to
the next filter.


<P>
The filter accepts a list of pixel format names, separated by ":",
for example "yuv420p:monow:rgb24".


<P>
The following command:



<PRE>
./ffmpeg -i in.avi -vfilters "format=yuv420p" out.avi
</PRE>

<P>
will convert the input video to the format "yuv420p".




<H2><A NAME="SEC9" HREF="libavfilter.html#TOC9">4.5 fps</A></H2>


<PRE>
./ffmpeg -i in.avi -vfilters "fps=30000:1001" out.avi
</PRE>

<P>
Modifies the framerate of the input video to a chosen one.




<H2><A NAME="SEC10" HREF="libavfilter.html#TOC10">4.6 hflip</A></H2>


<PRE>
./ffmpeg -i in.avi -vfilters "hflip" out.avi
</PRE>

<P>
Flip the video horizontally.




<H2><A NAME="SEC11" HREF="libavfilter.html#TOC11">4.7 negate</A></H2>


<PRE>
./ffmpeg -i in.avi -vfilters "negate" out.avi
</PRE>

<P>
Convert a video to its negative.
  


<H2><A NAME="SEC12" HREF="libavfilter.html#TOC12">4.8 noformat</A></H2>

<P>
Force libavfilter not to use any of the specified pixel formats for the
input to the next filter.


<P>
The filter accepts a list of pixel format names, separated by ":",
for example "yuv420p:monow:rgb24".


<P>
The following command:



<PRE>
./ffmpeg -i in.avi -vfilters "noformat=yuv420p, vflip" out.avi
</PRE>

<P>
will make libavfilter use a format different from "yuv420p" for the
input to the vflip filter.




<H2><A NAME="SEC13" HREF="libavfilter.html#TOC13">4.9 null</A></H2>

<P>
Pass the source unchanged to the output.




<H2><A NAME="SEC14" HREF="libavfilter.html#TOC14">4.10 overlay</A></H2>

<P>
Overlay one video on top of another (see the example in the introduction
section).
Be aware that frames are taken
from each input video in timestamp order, hence, if their initial
timestamps differ, it is a a good idea to pass the two
inputs through a <VAR>setpts=PTS-STARTPTS</VAR> filter to have them
begin in the same zero timestamp, as it does the example for
the <VAR>movie</VAR> filter.


<P>
Parameters to the filter are separated by a colon. The first parameter
is the x coordinate of the overlay, the second parameter is the y
coordinate. The parameters need not be constant expressions, but may
be expressions containing the names <VAR>mainW</VAR>, <VAR>mainH</VAR>,
<VAR>overlayW</VAR> and <VAR>overlayH</VAR>, for the size of the first and second
input video, respectively. For example,

<PRE>
overlay=mainW-overlayW-10:mainH-overlayH-10
</PRE>

<P>
can be used to draw the overlay at 10 pixels from the bottom right
corner of the main video.


<P>
The filter accepts a third optional parameter, if set to a value
different than 0, it will alpha-blend the overlayed video on top of
the first one.


<P>
This can be used in particular for performing watermarking effects, or
for adding a logo on top of the input video.


<P>
For example, the following command will insert a transparent PNG
logo in the bottom left corner of the input video:

<PRE>
movie=0:png:logo.png [logo]; [in][logo] overlay=10:mainH-overlayH-10:1 [out]
</PRE>

<P>
Notice the last parameter to overlay ":1" - this enables alpha blending.


<P>
The following example will insert 2 different transparent PNG
logos (second logo on bottom right corner):

<PRE>
movie=0:png:logo1.png [logo1];
movie=0:png:logo2.png [logo2];
[in][logo1] overlay=10:mainH-overlayH-10:1 [in+logo1];
[in+logo1][logo2] overlay=mainW-overlayW-10:mainH-overlayH-10:1 [out]
</PRE>

<P>
You could chain and add more overlays this way but the efficiency of
such approach is yet to be tested.




<H2><A NAME="SEC15" HREF="libavfilter.html#TOC15">4.11 pad</A></H2>

<P>
Add paddings to the input image, and places the original input at the
given coordinates x, y.


<P>
It accepts the following parameters: width:height:x:y:color.


<P>
Follows the description of the accepted parameters.


<DL COMPACT>

<DT><SAMP>`width, height'</SAMP>
<DD>
Specify the size of the output image with the paddings added. If the
value for "width" or "height" is 0, the corresponding input size
is used for the output.

The default value of "width" and "height" is 0.

<DT><SAMP>`x, y'</SAMP>
<DD>
Specify the offsets where to place the input image in the padded area
with respect to the top/left border of the output image.

The default value of "x" and "y" is 0.

<DT><SAMP>`color'</SAMP>
<DD>
Specify the color of the padded area, it can be the name of a color
(case insensitive match) or a 0xRRGGBB[AA] sequence.

The default value of "color" is "black".

</DL>



<H2><A NAME="SEC16" HREF="libavfilter.html#TOC16">4.12 rotate</A></H2>


<PRE>
./ffmpeg -i in.avi -vfilters "rotate=30" out.avi
</PRE>

<P>
Rotate video by a chosen amount in degrees. By default, 45 degrees.




<H2><A NAME="SEC17" HREF="libavfilter.html#TOC17">4.13 scale</A></H2>

<P>
Scale the input video to width:height and/or convert the image format.


<P>
For example the command:



<PRE>
./ffmpeg -i in.avi -vfilters "scale=200:100" out.avi
</PRE>

<P>
will scale the input video to a size of 200x100.


<P>
If the input image format is different from the format requested by
the next filter, the scale filter will convert the input to the
requested format.


<P>
If the value for "width" or "height" is 0, the respective input
size is used for the output.


<P>
If the value for "width" or "height" is -1, the scale filter will
use, for the respective output size, a value that maintains the aspect
ratio of the input image.


<P>
The default value of "width" and "height" is 0.




<H2><A NAME="SEC18" HREF="libavfilter.html#TOC18">4.14 setpts</A></H2>


<PRE>
# Start counting PTS from zero
ffmpeg -i input.avi -vfilters setpts=PTS-STARTPTS output.avi

# Fast motion
ffmpeg -i input.avi -vfilters setpts=0.5*PTS output.avi

# Fixed rate 25 fps
ffmpeg -i input.avi -vfilters setpts=N*AVTB/25 output.avi

# Fixed rate 25 fps with some jitter
ffmpeg -i input.avi -vfilters 'setpts=AVTB/25*(N+0.05*sin(N*2*PI/25))' output.avi
</PRE>

<P>
Modifies the presentation timestamp (PTS) of the input video.




<H2><A NAME="SEC19" HREF="libavfilter.html#TOC19">4.15 slicify</A></H2>

<P>
Pass the images of input video on to next video filter as multiple
slices.



<PRE>
./ffmpeg -i in.avi -vfilters "slicify=32" out.avi
</PRE>

<P>
The filter accepts the slice height as parameter. If the parameter is
not specified it will use the default value of 16.


<P>
Adding this in the beginning of filter chains should make filtering
faster due to better use of the memory cache.




<H2><A NAME="SEC20" HREF="libavfilter.html#TOC20">4.16 split</A></H2>

<P>
See the example in the introduction section.
The input video is passed on to two outputs.




<H2><A NAME="SEC21" HREF="libavfilter.html#TOC21">4.17 transpose</A></H2>


<PRE>
./ffmpeg -i in.avi -vfilters "transpose" out.avi
</PRE>

<P>
Transpose (line =&#62; column) input video to next video filter.




<H2><A NAME="SEC22" HREF="libavfilter.html#TOC22">4.18 unsharp</A></H2>

<P>
Sharpen or blur the input video. It accepts the following parameters:


<TABLE BORDER>

@headitem Name </TD><TD> Description </TD><TD> Min </TD><TD> Max </TD><TD> Default
<TR><TD><VAR>luma_msize_x</VAR></TD>

</TD><TD> Luma matrix horizontal size
</TD><TD> 3
</TD><TD> 13
</TD><TD> 5
</TR>
<TR><TD><VAR>luma_msize_y</VAR></TD>

</TD><TD> Luma matrix vertical size
</TD><TD> 3
</TD><TD> 13
</TD><TD> 5
</TR>
<TR><TD><VAR>luma_amount</VAR></TD>

</TD><TD> Luma effect strength
</TD><TD> -2.0
</TD><TD> 5.0
</TD><TD> 1.0
</TR>
<TR><TD><VAR>chroma_msize_x</VAR></TD>

</TD><TD> Chroma matrix horizontal size
</TD><TD> 3
</TD><TD> 13
</TD><TD> 0
</TR>
<TR><TD><VAR>chroma_msize_y</VAR></TD>

</TD><TD> Chroma matrix vertical size
</TD><TD> 3
</TD><TD> 13
</TD><TD> 0
</TR>
<TR><TD><VAR>chroma_amount</VAR></TD>

</TD><TD> Chroma effect strength
</TD><TD> -2.0
</TD><TD> 5.0
</TD><TD> 0.0
</TR></TABLE>

<P>
Negative values for the amount will blur the input video, while positive
values will sharpen. All parameters are optional and default to the
equivalent of the string '5:5:1.0:0:0:0.0'.



<PRE>
# Strong luma sharpen effect parameters
unsharp=7:7:2.5

# Strong blur of both luma and chroma parameters
unsharp=7:7:-2:7:7:-2

# Use the default values with <CODE>ffmpeg</CODE>
./ffmpeg -i in.avi -vfilters "unsharp" out.mp4
</PRE>



<H2><A NAME="SEC23" HREF="libavfilter.html#TOC23">4.19 vflip</A></H2>

<P>
Flip the input video vertically.



<PRE>
./ffmpeg -i in.avi -vfilters "vflip" out.avi
</PRE>



<H1><A NAME="SEC24" HREF="libavfilter.html#TOC24">5. Available video sources</A></H1>

<P>
Below is a description of the currently available video sources.




<H2><A NAME="SEC25" HREF="libavfilter.html#TOC25">5.1 buffer</A></H2>

<P>
This input filter is used by the client application to feed pictures to
the filter chain. See ffmpeg.c for an usage example.




<H2><A NAME="SEC26" HREF="libavfilter.html#TOC26">5.2 movie</A></H2>

<P>
The parameters of the movie filter are

<PRE>
 seekpoint in microseconds : string format : string filename
</PRE>

<P>
We can overlay a second movie on top of a main one as in this graph:



<PRE>
 input -----------&#62; deltapts0 --&#62; overlay --&#62; output
                                    ^
 movie --&#62; scale--&#62; deltapts1 ------|
</PRE>

<P>
To do that



<PRE>
ffmpeg -i in.avi -s 240x320 -vfilters "[in]setpts=PTS-STARTPTS, [T1]overlay=16:16[out]; movie=3200000:avi:in.avi, scale=180:144, setpts=PTS-STARTPTS[T1]" -y out.avi
</PRE>



<H2><A NAME="SEC27" HREF="libavfilter.html#TOC27">5.3 nullsrc</A></H2>

<P>
Null video source, never return images. It is mainly useful as a
template and to be employed in analysis / debugging tools.


<P>
It accepts as optional parameter a string of the form
"width:height", where "width" and "height" specify the size of
the configured source.


<P>
The default values of "width" and "height" are respectively 352
and 288 (corresponding to the CIF size format).




<H1><A NAME="SEC28" HREF="libavfilter.html#TOC28">6. Available video sinks</A></H1>

<P>
Below is a description of the currently available video sinks.




<H2><A NAME="SEC29" HREF="libavfilter.html#TOC29">6.1 nullsink</A></H2>

<P>
Null video sink, do absolutely nothing with the input video. It is
mainly useful as a template and to be employed in analysis / debugging
tools.


<P><HR><P>
This document was generated on 15 April 2010 using
<A HREF="http://wwwinfo.cern.ch/dis/texi2html/">texi2html</A>&nbsp;1.56k.
</BODY>
</HTML>
